import axios from 'axios'

//列表渲染
export function fetchList(params) {
  return axios({
    url: 'http://localhost:3001/data',
    method: 'GET',
    params
  })
}

//新增任务
export function fetchaddTask(data) {
  return axios({
    url: 'http://localhost:3001/data',
    method: 'POST',
    data
  })
}

//编辑回显任务
export function fetcheditTask(id) {
  return axios({
    url: `http://localhost:3001/data/${id}`,
    method: 'GET'
  })
}

//删除任务
export function fetchdelTask(id) {
  return axios({
    url: `http://localhost:3001/data/${id}`,
    method: 'DELETE'
  })
}

//编辑任务
export function editsTask(data) {
  return axios({
    url: `http://localhost:3001/data/${data.id}`,
    method: 'PUT',
    data
  })
}

//搜索任务
export function searchTask(value) {
  return axios({
    url: `http://localhost:3001/data/?name=${value}`,
    method: 'GET'
  })
}
